package com.ldq.imooc.service;

import com.ldq.imooc.bean.Message;
import com.ldq.imooc.dao.MessageDao;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author : 李道泉
 * @Description : 维护相关操作
 * @Date : 2018/9/13 13:58
 * @Modified by :
 */
public class MaintainService {

    public void insertOne(Message message) {

        MessageDao messageDao = new MessageDao();
        messageDao.insertOne(message);
    }

    /**
     * 单条删除
     *
     * @param id
     */
    public void deleteOne(String id) {

        if (id != null && !"".equals(id.trim())) {
            MessageDao messageDao = new MessageDao();
            messageDao.deleteOne(Integer.valueOf(id));
        }
    }

    /**
     * 批量删除
     *
     * @param ids
     */
    public void deleteBatch(String[] ids) {

        MessageDao messageDao = new MessageDao();
        List<Integer> idsList = new ArrayList<Integer>();
        for (String id : ids) {
            idsList.add(Integer.valueOf(id));
        }
        messageDao.deleteBatch(idsList);
    }
}
